import java.util.Random;
import java.util.Scanner;

public class Practice01 {
    static int grop = 11;
    public static void main(String[] args) {
        //获取操作次数
        //生成随机数
        Random rand = new Random();
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入你操作的步骤数");
        int number = sc.nextInt();
        int[] type = new int[number];
        for (int i = 0; i <number ; i++) {
            type[i] = rand.nextInt(4) + 1;
        }
        int count = 0;
        for (int i = 0; i <type.length ; i++) {
            switch (type[i]) {
                case 1:
                    grop += water();
                    System.out.println("浇水成功，成长值加10");
                    System.out.println("成长值为：" + grop);
                    break;
                case 2:
                    grop += cut();
                    System.out.println("修剪成功，成长值加5");
                    System.out.println("成长值为：" + grop);
                    break;
                case 3:
                    grop += ferttlixe();
                    System.out.println("打药成功，成长值加20");
                    System.out.println("成长值为：" + grop);
                    break;
                case 4:
                    grop += wowrms();
                    System.out.println("小树生虫了，成长值减10");
                    System.out.println("成长值为：" + grop);
                    count ++;
                    break;

            }
            if (grop <= 0){
                System.out.println("你的树已死亡，请重新栽植");
                break;
            }
            if (count == 3){
                System.out.println("已经连续生虫三次了，成长值减30");
                grop  -=30;
                System.out.println("成长值为：" + grop);
                count = 0;
                if (grop <= 0) {
                    System.out.println("你的树已死亡，请重新栽植");
                    break;
                }
            }
        }
    }
    public static int water(){
        int grop =0;
        grop += 10;
        return grop;
    }
    public  static int cut() {
        int grop =0;
        grop += 5;
        return grop;
    }
    public  static  int ferttlixe(){
        int grop =0;
        grop += 20;
        return  grop;
    }
    public  static  int  wowrms(){
        int grop =0;
        grop -= 10;
        return grop;
    }
}
